package com.top.ruizhong.main.host

import com.blankj.utilcode.util.BarUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.google.android.flexbox.FlexDirection
import com.google.android.flexbox.FlexWrap
import com.google.android.flexbox.FlexboxLayoutManager
import com.module.lemlin.base.BaseAbstractFragment
import com.top.ruizhong.R
import kotlinx.android.synthetic.main.fragment_search_record.*

class SearchRecordFragment : BaseAbstractFragment() {

    companion object {
        fun newInstance(): SearchRecordFragment {
            return SearchRecordFragment()
        }

        val tags: MutableList<String> = mutableListOf(
            "雅咔摄影社",
            "RxJava",
            "詹皇球迷社",
            "面包",
            "胶片机",
            "iPhoneX",
            "雅咔摄影社",
            "迪丽热巴",
            "机械键盘"
        )
    }

    private val tagAdapter =
        object : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_search_record) {
            override fun convert(holder: BaseViewHolder, item: String) {
                holder.setText(R.id.tvSearchTag, item)
            }
        }

    override val layoutResId: Int
        get() = R.layout.fragment_search_record

    override fun initView() {

        rvSearchRecordBody.apply {
            val layoutManager: FlexboxLayoutManager =
                FlexboxLayoutManager(requireContext(), FlexDirection.ROW, FlexWrap.WRAP)
            this.layoutManager = layoutManager
        }.adapter = tagAdapter.apply {
            setNewInstance(tags)
        }

        rvSearchPopularBody.apply {
            val layoutManager: FlexboxLayoutManager =
                FlexboxLayoutManager(requireContext(), FlexDirection.ROW, FlexWrap.WRAP)
            this.layoutManager = layoutManager
        }.adapter = tagAdapter.apply {
            setNewInstance(tags)
        }
    }

}